package com.gouaixin.bee.beeframework2.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ab.util.AbToastUtil;
import com.gouaixin.bee.beeframework2.R;
import com.gouaixin.bee.beeframework2.bean.USER;
import com.gouaixin.bee.beeframework2.model.MemberModel;
import com.gouaixin.bee.beeframework2.tool.mLog;

/**
 * Created by Administrator on 2015/3/26.
 */
//退款
public class Refund_fragment extends Fragment {
    View mainView;

    LinearLayout tuikuanBg;
    TextView tuikuan;

    int flag;//当前所在的父Activity
    public static final int FatherType_VIP = 0;//VIP
    public static final int FatherType_Hongniang = 1;//VIP
    public static final int FatherType_Baoyue = 2;//VIP
    public static final int FatherType_Aibi = 3;//VIP
    public static final int FatherType_Ybi = 4;//VIP

    public int getFlag() {
        return flag;
    }

    public void setFlag(int flag) {
        this.flag = flag;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        tuikuanBg= (LinearLayout) inflater.inflate(R.layout.tuikuan,null);
        intiTuikuan();
        return tuikuanBg;
    }

    private void intiTuikuan() {

        tuikuan= (TextView) tuikuanBg.findViewById(R.id.tuikuan);
        tuikuan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                int mType=getFlag();
                AbToastUtil.showToast(getActivity(), "您目前没有付费，暂时不能申请退款哟！");
            }
        });

        //未vip，显示
       MemberModel.getUSER(getActivity(), new MemberModel.GetUserLister() {
           @Override
           public void onSuccess(USER user) {
               int ktType=user.getVipType()+user.getBaoyueType()+user.getAbiType()+user.getYbiType()+user.getHongniangType();
               //如果是开通过任何项目
               if (ktType > 0) {
                   mLog.e("执行：   tuikuanBg.setVisibility(View.INVISIBLE);");
                   tuikuanBg.setVisibility(View.GONE);

               }
               //没有开通过
               else {
                   mLog.e("执行：  tuikuanBg.setVisibility(View.VISIBLE);");
                   tuikuanBg.setVisibility(View.VISIBLE);
               }
           }

           @Override
           public void onFailure(int i, String s) {

           }
       });



    }




}
